package com.hk.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AccountDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void DecMoney(int money,String name){
        System.out.println("执行DecMoney方法,参数是："+money+","+name);
        String sql="update account set money=money-? where name=?";
        int update = jdbcTemplate.update(sql, money, name);
        System.out.println("执行DecMoney方法结束");
    }
    public void AddMoney(int money,String name)throws ArithmeticException{

        System.out.println("执行AddMoney方法,参数是："+money+","+name);
        String sql="update account set money=money+? where name=?";
        int update = jdbcTemplate.update(sql, money, name);
        System.out.println("执行AddMoney方法结束");
        int i=1/0;
    }
    public void dealhalf(){
        String sql = "update account set money=0 where id= '5' ";
        jdbcTemplate.update(sql);
    }
}
